package org.example.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2024/3/15 11:34
 * @apiNote
 */

public class Test00145PostorderTraversal {
    public List<Integer> postorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        backOrder(root,res);
        return res;
    }

    public void backOrder(TreeNode root, List<Integer> res){
        if(root == null){
            return;
        }
        backOrder(root.left,res);
        backOrder(root.right,res);
        res.add(root.val);
    }
}
